package com.yue.pattern.singleton;

/**
 * 懒汉模式双重检查， 线程安全，推荐使用
 * Created by qiuyang on 06/04/2017.
 */
public class LazyDoubleSyncSingleton {
    private static LazyDoubleSyncSingleton singleton;

    private LazyDoubleSyncSingleton() {}

    public static LazyDoubleSyncSingleton getInstance() {
        if (singleton == null) {
            synchronized (LazyDoubleSyncSingleton.class) {
                if (singleton == null) {
                    singleton = new LazyDoubleSyncSingleton();
                }
            }
        }

        return singleton;
    }
}
